package com.zhongzhi.nn.push.configure;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;

public class JdbcConstants {
	
	private static Map<String,String> jdbcMap = new HashMap<String, String>();
	
	public static final String jdbc_driverClassName = "jdbc.driverClassName";
	
    public static final String jdbc_url = "jdbc.url";
    
    public static final String jdbc_username = "jdbc.username";
    
    public static final String jdbc_password = "jdbc.password";
    
    
    static{
    	PropertiesConfiguration config;
		try {
			config = new PropertiesConfiguration("jdbc.properties");
			put(jdbc_driverClassName,config.getString(jdbc_driverClassName));
			put(jdbc_url,config.getString(jdbc_url));
			put(jdbc_username,config.getString(jdbc_username));
			put(jdbc_password,config.getString(jdbc_password));
		} catch (ConfigurationException e) {
			e.printStackTrace();
		}
    }
    
    public static Map<String,String> getMap(){
    	return jdbcMap;
    }
    
    /**
	 * 设置属性
	 * @param key
	 * @param value
	 */
	private static void put(final String key,final String value){
		try {
			if(jdbcMap != null){
				jdbcMap.put(key, value);
			}else{
				jdbcMap = new HashMap<String, String>();
				put(key,value);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
